package com.kingdee.hackson.utils;


public class AdminStructNumberUtils {

    public static String encodeStructNumber(String code26) {
        StringBuilder result = new StringBuilder();
        int length = code26.length();
        for (int i = 2; i <= length; i += 2) {
            String substring = code26.substring(0, i);
            if ("0a".equals(substring)) {
                result.append("00").append("!");
                continue;
            }
            Long superId = OrgCodeConvertUtils.decode26Code(substring);
            Long aLong = IDConvertUtils.encodeToLongId(superId);
            String superCode = Base39Utils.toString(aLong);
            result.append(superCode).append("!");
        }
        if (result.toString().endsWith("!")) {
            return result.substring(0, result.length() - 1);
        }
        return result.toString();
    }

    public static void main(String[] args) {
        // 0b0a 1269600871000000103-1269600871000000412
        String adminCode = AdminStructNumberUtils.encodeStructNumber("0a0b");
        String parentId = Base39Utils.toString(1269600871000000103L);
        String childId = Base39Utils.toString(1269600871000000412L);
        System.out.println("adminCode =" + adminCode + ",parentId=" + parentId + ",childId=" + childId);
    }
}
